<!-- @ 个人日报详情 -->
<template>
	<view v-if="mode&&mode.order">
		<u-notify ref="uNotify" />
		<loadFlex :loading="loading" />

		<view class="cu-bar bg-cyan">
			<view class="action" @click="handeBack">
				<text class="cuIcon-back text-white"></text> 返回
			</view>
			<view class="content text-bold">
				{{mode.order.username}}个人日报
			</view>
		</view>
		<uni-card margin="1" :is-shadow="false" padding="0">
			<template v-slot:title>
				<view class="flex padding-tb-sm solid-bottom align-center justify-between">
					<view>
						{{mode.order.dailyTitle}}
					</view>
					<view class="text-cyan">{{mode.order.username}}</view>
				</view>
			</template>
			<view class="flex padding-bottom  flex-direction ">
				<view class="flex  margin-top-sm">
					创建日期：{{mode.order.createTime}}
				</view>
				<view v-if="mode.order.picPath" class="solid margin-top-sm">
					<!-- <view class="bg-cyan padding-left-xs">图片</view> -->
					<view class="cu-avatar-group margin-tb-sm">
						<view class="cu-avatar round " style="margin-left:-8px !important" @click.stop="handeImage(index2)"
							v-for="(item2,index2) in handItyCard(mode.order.picPath)" :key="index2"
							:style="[{ backgroundImage:'url(' + item2 + ')' }]"></view>
					</view>
				</view>
				<view class="flex flex-direction margin-top-sm ">
					<view v-for="(item,index) in mode.details" :key="index" :class="index !=0?'margin-top-sm':''">
						<uni-card margin="0" :is-shadow="false" padding="0">
				
							<template v-slot:title>
								<view class="flex padding-tb-xs solid-bottom align-center justify-between">
									<view class="flex align-center">
										<u-badge type="success" max="99999" :value="index + 1"
											class="margin-right-xs"></u-badge>基本信息
									</view>
								</view>
							</template>
							<view class="flex padding-tb-sm">
								<text>{{item.orderContent}}</text>
							</view>
						</uni-card>
					</view>
				</view>
			</view>
		</uni-card>
	</view>
</template>
<script>
	import myApi from '@/utils/app.js' //调用接口使用
	import loadFlex from '@/components/loadFlex/loadFlex.vue' //加载
	export default {
		components: {
			loadFlex,
		},
		data() {
			return {
				mode: {},
				loading: false,
				projectNo: '',
			}
		},
		onLoad(options) {
			if (options.projectId) {
				this.projectId = options.projectId
				this.loadData()
			}
		},
		computed: {
			handItyCard() {
				return function(text) {
					if (text) return text.split(",")
					return []
				}
			},
		},
		methods: {
			async loadData() {
				this.loading = true
				try {
					const res = await this.$request({
						url: myApi.bmsDailyNewOrderByID,
						method: 'GET',
						data: {
							id: this.projectId
						}
					});
					if (res.code == 200) {
						this.mode = res.result
						console.log(this.mode)
					}
				} catch (e) {
					// 失败执行
					console.log(`这个接口错误：${myApi.goodsList}`)
				} finally {
					// 销毁执行
					this.loading = false
				}
			},

			onNotify(round) { // 提示
				this.$refs.uNotify.show({
					type: round.type ? round.type : 'success',
					message: round.message ? round.message : '操作成功',
					top: 50
				})
			},
			handeImage(index) {
				const imgs = this.mode.order.picPath.split(",").map(item => {
					//只返回图片路径
					return item
				})
				//调用预览图片的方法
				uni.previewImage({
					urls: imgs,
					current: index
				})

			},
			handeBack(){
				uni.navigateBack({
				  delta: 1 // 返回的页面数
				});
			}
		}
	}
</script>
<style lang="scss" scoped>

</style>